import request from '@/utils/request'

/**
 * 获取房间列表
 * @param {Object} params 查询参数
 */
export const getRoomList = (params) => {
  return request({
    url: '/rooms',
    method: 'get',
    params
  })
}

/**
 * 根据ID获取房间详情
 * @param {number} id 房间ID
 */
export const getRoomById = (id) => {
  return request({
    url: `/rooms/${id}`,
    method: 'get'
  })
}

/**
 * 创建房间
 * @param {Object} data 房间数据
 */
export const createRoom = (data) => {
  return request({
    url: '/rooms',
    method: 'post',
    data
  })
}

/**
 * 更新房间信息
 * @param {number} id 房间ID
 * @param {Object} data 房间数据
 */
export const updateRoom = (id, data) => {
  return request({
    url: `/rooms/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除房间
 * @param {number} id 房间ID
 */
export const deleteRoom = (id) => {
  return request({
    url: `/rooms/${id}`,
    method: 'delete'
  })
}

/**
 * 批量删除房间
 * @param {Array} ids 房间ID数组
 */
export const batchDeleteRooms = (ids) => {
  return request({
    url: '/rooms/batch',
    method: 'delete',
    data: { ids }
  })
}

/**
 * 根据房间号获取房间
 * @param {string} roomNumber 房间号
 */
export const getRoomByNumber = (roomNumber) => {
  return request({
    url: `/rooms/number/${roomNumber}`,
    method: 'get'
  })
}

/**
 * 根据状态获取房间列表
 * @param {string} status 房间状态
 */
export const getRoomsByStatus = (status) => {
  return request({
    url: `/rooms/status/${status}`,
    method: 'get'
  })
}

/**
 * 根据房间类型获取房间列表
 * @param {string} type 房间类型
 */
export const getRoomsByType = (type) => {
  return request({
    url: `/rooms/type/${type}`,
    method: 'get'
  })
}

/**
 * 根据类型和状态获取房间列表
 * @param {string} type 房间类型
 * @param {string} status 房间状态
 */
export const getRoomsByTypeAndStatus = (type, status) => {
  return request({
    url: `/rooms/type/${type}/status/${status}`,
    method: 'get'
  })
}

/**
 * 获取可用房间列表
 */
export const getAvailableRooms = () => {
  return request({
    url: '/rooms/available',
    method: 'get'
  })
}

/**
 * 根据楼层和状态获取房间列表
 * @param {number} floor 楼层
 * @param {string} status 房间状态
 */
export const getRoomsByFloorAndStatus = (floor, status) => {
  return request({
    url: `/rooms/floor/${floor}/status/${status}`,
    method: 'get'
  })
}

/**
 * 获取满员房间列表
 */
export const getFullRooms = () => {
  return request({
    url: '/rooms/full',
    method: 'get'
  })
}

/**
 * 根据容量范围获取房间列表
 * @param {number} minCapacity 最小容量
 * @param {number} maxCapacity 最大容量
 */
export const getRoomsByCapacityRange = (minCapacity, maxCapacity) => {
  return request({
    url: `/rooms/capacity-range`,
    method: 'get',
    params: { minCapacity, maxCapacity }
  })
}

/**
 * 获取房间统计信息
 */
export const getRoomStats = () => {
  return request({
    url: '/rooms/stats',
    method: 'get'
  })
}